package com.itheima.d5_recursion;

/**
 * 目标：掌握递归的应用，执行流程和算法思想。
 */
public class RecursionTest2 {
    public static void main(String[] args) {

        long test = test(10);
        System.out.println("阶乘：" + test);
        int i = test1(5);
        System.out.println("累加" + i);
    }

    public static long test(int sum) {
        if (sum == 1) {
            return 1;
        }
        return sum *= test(sum - 1);
    }

    public static int test1(int num) {
        if (num == 1) {
            return 1;
        }
        return num += test1(num - 1);
    }
}
